package thread;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/27
 * Time:19:34
 **/
public class ThreadDemo13 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                //while(!Thread.interrupted()){//判断线程的终止状态
                while(!Thread.currentThread().isInterrupted()){
                    System.out.println("正在转账");
                }
                System.out.println("终止线程");
            }
        });
        t1.start();

        Thread.sleep(10);
        System.out.println("有内鬼，终止交易");
        t1.interrupt();
    }
}
